from collections import Counter

class Solution:
    def numRabbits(self, answers: list[int]) -> int:
        counts = Counter(answers)
        total = 0
        for answer, freq in counts.items():
            group_size = answer + 1
            total += ((freq + group_size - 1) // group_size) * group_size
        return total    
